function insertParam(k, v = '') {
    let url = window.location.search;
    url = url.slice(1)
    let arr = url.split('&');
    let params = {}
    arr.forEach((ell) => {
        if (ell) {
            let [key, value] = ell.split("=");
            params[key] = value;
        }
    })
    if (k && v) {
        params[k] = v;
    }
    let urlSearch = []
    Object.entries(params).forEach(([key, val]) => {
        urlSearch.push(key + "=" + val);
    })
    return urlSearch.join("&");
}


function copyText(text) {
    let input = document.createElement("textarea");
    document.body.appendChild(input)
    input.value = text
    input.select()
    document.execCommand("COPY");
    input.remove();
}

function formatBytes(bytes) {
    if (!bytes) {
        bytes = 0;
    }
    if (bytes < 1000) {
        return bytes + ' KB';
    } else if (bytes < 1000000) {
        return (bytes / 1000).toFixed(2) + ' MB';
    } else if (bytes < 1000000000) {
        return (bytes / 1000000).toFixed(2) + ' GB';
    } else {
        return (bytes / 1000000000).toFixed(2) + ' TB';
    }
}